<HTML><HEAD><TITLE>retractall(+Head)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Dynamic Predicates</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>retractall(+Head)</H1>
Removes from the database all clauses whose heads match Head
<DL>
<DT><EM>Head</EM></DT>
<DD>Atom, variable or compound term.
</DD>
</DL>
<H2>Description</H2>
   Retracts from the database all clauses whose heads match the argument.
   The argument must be sufficiently instantiated otherwise an error is
   signalled.  retractall/1 never fails.  The clauses are not reasserted
   when backtracking through the call of retractall/1.

<P>
   The functor and the arity of Head must be that of a predicate declared
   as dynamic (or implicitly declared as dynamic by asserting).

<P>
   retractall/1 satisfies the logical update semantics.  Using it to
   retract all the clauses of a predicate will not, in any way, affect
   previous calls to the predicate, i.e. they will still see all the clauses
   that existed at call time.

<P>

<H3>Modes and Determinism</H3><UL>
<LI>retractall(+) is det
</UL>
<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Head is not instantiated
<DT><EM>(5) type error </EM>
<DD>Head is not a callable term
<DT><EM>(63) procedure not dynamic </EM>
<DD>Procedure is not dynamic
<DT><EM>(70) accessing an undefined dynamic procedure </EM>
<DD>Procedure is undefined
</DL>
<H2>Examples</H2>
<PRE>
Success:
    [eclipse]: assert(city(munich)), assert(city(london)).
    yes.
    [eclipse]: retractall(city(_)).
    yes.
    [eclipse]: city(X).
    no (more) solution.
    [eclipse]: retractall(city(_)).
    yes.
Error:
    retractall(X).                  (Error 4).
    retractall("x").                (Error 5).


   % if h/0 is defined, but not as dynamic..
    retractall(h).                  (Error 63).

    retractall(z/0).                (Error 70).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/dynamic/dynamic-1.html">dynamic / 1</A>, <A HREF="../../kernel/dynamic/assert-1.html">assert / 1</A>, <A HREF="../../kernel/dynamic/retract-1.html">retract / 1</A>
</BODY></HTML>
